import * as bm from "/js/baseModule.js";

export class Module extends bm.baseModule {
    constructor(view) {
        super(view);
        let that = this;
        that.payMoney = 2500;
        this.find('.span-range').on("input", function (e) {
            var width = that.find(".span-range").width();
            //取得point个数
            //m% * (最大值 - 最小值) + 最小值;
            // let currSpan = this.value / 100 * 9000 + 1000;
            let currSpan =  Math.floor(this.value / 100 * 90) * 100 + 1000;
            //half-point 相对位置
            let hp = that.find(".half-point").width();
            let tp = that.find(".total-point").width();
            let a = (width * this.value / 100 - hp / 2) / width * 100;
            let b = (width * this.value / 100 - tp / 2) / width * 100;
            if (this.value <= 10) {
                a = a + 3;
                b = b + 3;
            } else if (this.value > 10 && this.value <= 20) {
                a = a + 2;
                b = b + 2;
            } else if (this.value > 20 && this.value <= 30) {
                a = a + 1;
                b = b + 1;
            } else if (this.value >= 60 && this.value < 70) {
                a = a - 1;
                b = b - 1;
            } else if (this.value >= 70 && this.value < 80) {
                a = a - 2;
                b = b - 2;
            } else if (this.value >= 80 && this.value <= 100) {
                a = a - 3;
                b = b - 3;
            }
            $('.blue-cover').css('width', this.value + '%');
            $('.half-point').css('left', a + '%').html(currSpan + "个" + '<em class="horn"></em>');
            $('.total-point').css('left', b + '%').html("&yen;" + currSpan * 0.9);
            that.payMoney = currSpan;
        }).on('change', function (e) {
            //取得当前个数
            let currSpan = Math.floor(this.value / 100 * 90) * 100 + 1000;

        });

    }
    afterInstall(){
        let content = this.config.parent.find('.CenterModalContent');
        let height = content.height();
        content.css('margin-top', -height / 2 + 'px');
        setTimeout(function () {
            content.css({'transform': 'scale(1,1)', 'opacity': '1'});
        }, 100);
    }
    /**充值*/
    _evt_recharge() {
        this._evt_goback();
        /**
         * 微信支付
         */
        AppUtil.jsCallAppParam("22", {"bid_point":this.payMoney});
    }
}
